package boardgamer.yavalath.client;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.LightingColorFilter;
import android.graphics.Paint;
import android.graphics.RectF;
import boardgamer.common.client.Display;
import boardgamer.common.client.layout.BitmapLayout;
import boardgamer.yavalath.client.resources.ImageHandler;

/**
 * @author garysoed
 */
public class GlowHex implements Display {

  private final BitmapLayout glow;

  public static GlowHex verticalHex(Display drawable, int glowColor) {
    return new GlowHex(drawable, ImageHandler.tileVerticalGlow, glowColor);
  }

  public static GlowHex horizontalHex(Display drawable, int glowColor) {
    return new GlowHex(drawable, ImageHandler.tileGlow, glowColor);
  }

  private GlowHex(Display button, Bitmap glow, int glowColor) {
    Paint glowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    glowPaint.setColorFilter(new LightingColorFilter(glowColor, 0));

    this.glow = new BitmapLayout(glow, glowPaint);
    this.glow.setBoundingRect(button.getBoundingRect());
  }

  @Override
  public void draw(Canvas canvas) {
    glow.draw(canvas);
  }

  @Override
  public void setBoundingRect(RectF boundingRect) {
    glow.setBoundingRect(boundingRect);
  }

  @Override
  public RectF getBoundingRect() {
    return new RectF(glow.getBoundingRect());
  }
}
